package cn.gzmli.dtt.common.entity;


import javax.servlet.http.HttpSession;
import java.util.List;


/**
 * 用户基本信息和权限信息
 * @author wonderful
 * @create 20150708
 */
public class UserInfo {

	//用户对象
	private User user;

	//用户角色集合
	private List<Role> roles;
	//用户部门集合
	private List<Department> orgs;

	//用户菜单ID集合字符串，多个ID以','号分隔
	private String menuIDsStr;
	//用户机构名称集合字符串，多个名称以','号分隔
	private String orgNamesStr;
	//用户当前的会话
	private HttpSession userSession;

	public UserInfo(User user, List<Role> roles, List<Department> orgs, HttpSession userSession){
		this.roles=roles;
		this.orgs=orgs;
		this.user=user;
		this.userSession=userSession;
		userSession.setAttribute("UserInfo",this);
		//记录用户登录状态，1正常登录，3重复登录
		userSession.setAttribute("loginState",1);
//		if(roles!=null)
//		{
//			menuIDsStr="";
//			for(int i=0;i<roles.size();i++){
//				Role role=roles.get(i);
//				if(role.getMenus()!=null){
//					if(i+1==roles.size()){
//						menuIDsStr+= StrUtil.join(",", role.getMenus().toArray());
//						break;
//					}
//					menuIDsStr+=role.getMenuIDS()+",";
//				}
//			}
//		}
//
//		if(orgs!=null)
//		{
//			orgNamesStr="";
//			for(int i=0;i<orgs.size();i++){
//				Org org=orgs.get(i);
//				if(org.getName()!=null&&!org.getName().equals("")){
//					if(i+1==orgs.size()){
//						orgNamesStr+=org.getName();
//						break;
//					}
//					orgNamesStr+=org.getName()+",";
//				}
//			}
//		}
	}

	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public List<Role> getRoles() {
		return roles;
	}
	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public HttpSession getUserSession() {
		return userSession;
	}
	public void setUserSession(HttpSession userSession) {
		this.userSession = userSession;
	}
	public String getMenuIDsStr() {
		return menuIDsStr;
	}
	public void setMenuIDsStr(String menuIDsStr) {
		this.menuIDsStr = menuIDsStr;
	}
	public String getOrgNamesStr() {
		return orgNamesStr;
	}
	public void setOrgNamesStr(String orgNamesStr) {
		this.orgNamesStr = orgNamesStr;
	}




}
